<?php

class MyMemcache {

	private $mc;

	function MyMemcache($options) {
		$this->mc = new Memcache;
		// if(!isset($options['servers'])) {
		// 	$options['servers'] = array(
		// 	array('localhost', 11211, 100),
		// 	);
		// }
		// foreach($options['servers'] as $serv)
		// 	$this->mc->addServer($serv[0],$serv[1],0,$serv[2]);
		$this->mc->connect($options['host'],$options['port']);
		// echo 'connect memcache';
	}

	public function get($key) {
		$tmp = $this->mc->get($key);
		return $tmp;
	}

	public function set($key, $data, $ttl = 600 ,$flag = 0) {
		$this->mc->set($key, $data, $flag, $ttl);
	}

	public function replace($key, $data) {
		$this->mc->replace($key, $data,0);
	}
	
	public function delete($key) {
		$this->mc->delete($key);
	}

	public function flush() {
		$this->mc->flush();
	}
	
	public function increment($key, $value = 1) {
		$this->mc->increment($key, $value);
	}
	
	public function decrement($key, $value = 1) {
		$this->mc->increment($key, $value);
	}
}